#ifndef CQTOPENCVVIEWERGL_H
#define CQTOPENCVVIEWERGL_H

#include <QGLWidget>
#include <opencv/cv.h>


class CQtOpenCVViewerGl : public QGLWidget
{
    Q_OBJECT
public:
    explicit CQtOpenCVViewerGl(QWidget *parent = 0);
    
private:
    bool mSceneChanged; /// Indicates when OpenGl view is to be redraw

    QImage mRenderQtImg; /// Qt Image to be rendered
    cv::Mat mOriginImage; /// original OpenCV image to be shown

    QColor mBgColor; /// Background Color

    int mOutH; /// resized image height
    int mOutW; /// resized image width
    float mImratio; /// height/width ratio

    int mPosX; /// Top Left X position to reder image in the center of the widget
    int mPosY; /// Top Left Y position to reder image in the center of the widget

protected:
    /*OpenGl methods*/
    void initializeGL();
    void paintGL();
    void resizeGL(int w, int h);

    void updateScene(); /// Forces a Scene to Update
    void renderImage(); /// Render Image on openGL frame

signals:
    void imageSizeChanges (int outW, int outH); /// used to resize image outside the widget

public slots:
    bool showImage (cv::Mat image); /// Used to set the Image to be viewed
    
};

#endif // CQTOPENCVVIEWERGL_H
